from PyQt5.QtWidgets import *
from PyQt5 import QtCore
from PyQt5.QtCore import QPropertyAnimation, QRect
from com.atzl.ui.MeassageUI import Ui_Form as mess_ui

# 消息提示框交互
class MessageWindow(QMainWindow):  # 继承:QMainWindow
    def __init__(self):
        QMainWindow.__init__(self)
        # 设置为全局小部件
        self.ui = mess_ui()
        self.m_flag = False
        self.ui.setupUi(self)
        global widgets
        widgets = self.ui

        widgets.pushButton_2.clicked.connect(self.close)  # 关闭消息提示框
        widgets.pushButton_3.clicked.connect(self.close)  # 关闭消息提示框

    # 设置提示框界面及动画
    def set_message(self, the_message):
        self.setWindowModality(QtCore.Qt.ApplicationModal)  # 禁止其他界面响应
        widgets.label_2.setText(the_message)  # 设置提示内容
        widgets.label_2.setAlignment(QtCore.Qt.AlignCenter)  # 设置提示内容文本居中显示
        self.anim = QPropertyAnimation(self, b"geometry")  # 设置动画对象
        self.anim.setDuration(125)  # 设置动画时长
        self.anim.setStartValue(QRect(750, 400, 100, 100))  # 设置初始属性
        self.anim.setEndValue(QRect(750, 400, 500, 500))  # 设置结束属性
        self.anim.start()  # 开始动画
        self.show()  # 显示消息提示框
